package net.sk.china.city.talk.dao.city;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.sk.china.city.talk.model.city.City;
import org.apache.ibatis.annotations.Select;

/**
 * 城市分站表 Mapper 接口
 * +----------------------------------------------------------------------
 * | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2018-2024 聊来All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">apache</a> )
 * +----------------------------------------------------------------------
 * | @Author: 聊来 <18970881148@qq.com>
 * +----------------------------------------------------------------------
 * | DateTime: 2024/6/11 15:35
 * +----------------------------------------------------------------------
 */
public interface CityDao extends BaseMapper<City> {

    /**
     * 根据城市编码获取超管账号是否存在
     * @param areaCode 城市编码
     * @return {@code City}
     */
    @Select("select * from db_city where parent_id = 0 and area_code = #{areaCode} limit 1")
    City getCheckAreaCodeInfo(String areaCode);

    /**
     * 根据城市编码获取超管账号是否存在（更新时）
     * @param areaCode 城市编码
     * @return {@code City}
     */
    @Select("select * from db_city where id != #{id} and parent_id = 0 and area_code = #{areaCode} limit 1")
    City getVerifyAreaCodeInfo(Integer id, String areaCode);
}
